<?php
	if (isset($_REQUEST['p'])) {
		$p = $_REQUEST['p'];
	} else {
		$p=0;
	}
	$limit = 15;
	$start = $p * $limit;
    $sql = "SELECT * FROM links LIMIT $start,$limit";
    $sql_all = "SELECT link from links";
    $all_links = mysql_query($sql_all, $con);
    $all_links = mysql_num_rows($all_links);
    if (!$result=mysql_query($sql, $con)) {
    	echo '<h2>Can not get links from database.</h2>';
    	exit();
    }
    $total_links=mysql_num_rows($result);
?>
	<div class="alert alert-info">There are <?=$all_links;?> links in database.</div>
<?php
  generate_table($result);
  generate_pagi($all_links, $limit, $p);
	$pagi=$all_links/$limit;
?>